package com.hluck.goodweatherapp.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hluck.goodweatherapp.data.bean.WeatherIndexResponse;
import com.hluck.goodweatherapp.data.bean.WeekWeather;
import com.hluck.goodweatherapp.databinding.ItemLifestyleRvBinding;

import java.util.List;

/**
 * @Author： LJH
 * @Time： 2024/1/3
 * @description：
 */
public class LifestyleAdapter extends RecyclerView.Adapter<LifestyleAdapter.ViewHolder> {

    private final List<WeatherIndexResponse.Index> dailyBeans;

    public LifestyleAdapter(List<WeatherIndexResponse.Index> dailyBeans) {
        this.dailyBeans = dailyBeans;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ItemLifestyleRvBinding binding = ItemLifestyleRvBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
        return new ViewHolder(binding);
    }

    @Override
    public void onBindViewHolder(LifestyleAdapter.ViewHolder holder, int position) {
        WeatherIndexResponse.Index index = dailyBeans.get(position);
        holder.binding.tvLifestyle.setText(index.getName()+"："+index.getText());
    }

    @Override
    public int getItemCount() {
        return dailyBeans.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{

        public ItemLifestyleRvBinding binding;


        public ViewHolder(ItemLifestyleRvBinding mbinding) {
            super(mbinding.getRoot());
            binding = mbinding;
        }
    }
}
